home *** CD-ROM | disk | FTP | other *** search
- /*
- stat.h -- an attempt to provide somewhat compatible stat functions
- for MPW.
-
- stat & fstat return:
-
- -1 on failure and sets errno.
- 0 on success
-
- Copyright (c) 1993 Anthony C. Ard.
-
- This program is free software; you can redistribute it and/or
- modifiy it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- #ifndef __STAT_HEADER__
- #define __STAT_HEADER__
-
- #include <time.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- struct stat
- {
- dev_t st_dev; /* MacOS volume reference number */
- ino_t st_ino; /* MacOS directory id or file number */
- unsigned short st_mode;
- short st_nlink; /* Not used */
- short st_uid; /* Not used */
- short st_gid; /* Not used */
- dev_t st_rdev; /* Not used */
- off_t st_size;
- time_t st_atime; /* MacOS Modification date */
- time_t st_crtime; /* MacOS Creation date */
- time_t st_mtime; /* MacOS Modification date */
- time_t st_bktime; /* MacOS Backup date */
- time_t st_ctime; /* MacOS Modification date */
- int st_spare3;
- long st_blksize;
- long st_blocks;
- long st_spare4[2];
- };
-
- #define S_IFMT 0xF000 /* type of file */
-
- #define S_IFDIR 0x4000 /* directory */
- #define S_IFCHR 0x2000 /* character special */
- #define S_IFBLK 0x6000 /* block special */
- #define S_IFREG 0x8000 /* regular */
- #define S_IFLNK 0xA000 /* symbolic link */
- #define S_IFSOCK 0xC000 /* socket */
- #define S_IFIFO 0x1000 /* fifo */
-
- #define S_ISUID 0x0800 /* set user id on execution */
- #define S_ISGID 0x0400 /* set group id on execution */
- #define S_ISVTX 0x0200 /* save swapped text even after use */
- #define S_IREAD 0x0100 /* read permission, owner */
- #define S_IWRITE 0x0080 /* write permission, owner */
- #define S_IEXEC 0x0040 /* execute/search permission, owner */
-
- #define S_IRUSR 0x0100 /* read permission, owner */
- #define S_IWUSR 0x0080 /* write permission, owner */
- #define S_IXUSR 0x0040 /* execute/search permission, owner */
- #define S_IRGRP 0x0020 /* read permission, group */
- #define S_IWGRP 0x0010 /* write permission, grougroup */
- #define S_IXGRP 0x0008 /* execute/search permission, group */
- #define S_IROTH 0x0004 /* read permission, other */
- #define S_IWOTH 0x0002 /* write permission, other */
- #define S_IXOTH 0x0001 /* execute/search permission, other */
- #define S_ENFMT 0x0000 /* enforcement-mode locking not implemented */
-
- #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
- #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
- #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
- #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
- #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
- #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
- #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
-
- int stat( const char *, struct stat * );
- int fstat( int, struct stat * );
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-